package edu.online.dal;

import edu.online.entity.PayInfoEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface PayInfoEntityMapper {
    @Delete({
        "delete from payinfo",
        "where PayInfoID = #{payinfoid,jdbcType=CHAR}"
    })
    int deleteByPrimaryKey(String payinfoid);

    @Insert({
        "insert into payinfo (PayInfoID, StudentId, ",
        "AdminUserId, PayMethod, ",
        "PayAmount, PayAccount, ",
        "PayTime, ConfirmTime)",
        "values (#{payinfoid,jdbcType=CHAR}, #{studentid,jdbcType=CHAR}, ",
        "#{adminuserid,jdbcType=CHAR}, #{paymethod,jdbcType=VARCHAR}, ",
        "#{payamount,jdbcType=INTEGER}, #{payaccount,jdbcType=VARCHAR}, ",
        "#{paytime,jdbcType=TIMESTAMP}, #{confirmtime,jdbcType=TIMESTAMP})"
    })
    int insert(PayInfoEntity record);

    @InsertProvider(type=PayInfoEntitySqlProvider.class, method="insertSelective")
    int insertSelective(PayInfoEntity record);

    @Select({
        "select",
        "PayInfoID, StudentId, AdminUserId, PayMethod, PayAmount, PayAccount, PayTime, ",
        "ConfirmTime",
        "from payinfo",
        "where PayInfoID = #{payinfoid,jdbcType=CHAR}"
    })
    @Results({
        @Result(column="PayInfoID", property="payinfoid", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="StudentId", property="studentid", jdbcType=JdbcType.CHAR),
        @Result(column="AdminUserId", property="adminuserid", jdbcType=JdbcType.CHAR),
        @Result(column="PayMethod", property="paymethod", jdbcType=JdbcType.VARCHAR),
        @Result(column="PayAmount", property="payamount", jdbcType=JdbcType.INTEGER),
        @Result(column="PayAccount", property="payaccount", jdbcType=JdbcType.VARCHAR),
        @Result(column="PayTime", property="paytime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="ConfirmTime", property="confirmtime", jdbcType=JdbcType.TIMESTAMP)
    })
    PayInfoEntity selectByPrimaryKey(String payinfoid);

    @UpdateProvider(type=PayInfoEntitySqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(PayInfoEntity record);

    @Update({
        "update payinfo",
        "set StudentId = #{studentid,jdbcType=CHAR},",
          "AdminUserId = #{adminuserid,jdbcType=CHAR},",
          "PayMethod = #{paymethod,jdbcType=VARCHAR},",
          "PayAmount = #{payamount,jdbcType=INTEGER},",
          "PayAccount = #{payaccount,jdbcType=VARCHAR},",
          "PayTime = #{paytime,jdbcType=TIMESTAMP},",
          "ConfirmTime = #{confirmtime,jdbcType=TIMESTAMP}",
        "where PayInfoID = #{payinfoid,jdbcType=CHAR}"
    })
    int updateByPrimaryKey(PayInfoEntity record);
}